﻿@page "/post/preview/{postId:guid}"
@model Moonglade.Web.Pages.PostPreviewModel
@using Moonglade.Utils

@{
    ViewBag.BodyClass = "body-post-slug";
}

@section meta {
    <meta name="robots" content="noindex, nofollow" />
    <meta name="title" content="@Model.Post.Title" />
    <meta name="author" content="@(string.IsNullOrWhiteSpace(Model.Post.Author) ? BlogConfig.GeneralSettings.OwnerName : Model.Post.Author) " />
}

@section head {
    <link href="~/css/post.css" rel="stylesheet" asp-append-version="true" />
    <link href="~/css/highlighter-custom.css" rel="stylesheet" asp-append-version="true" />
}

@section scripts {
    <script src="~/js/3rd/highlight.min.js" asp-append-version="true"></script>
    <script src="~/js/3rd/katex.min.js"></script>

    <script type="module">
        import * as viewpost from '/js/app/viewpost.module.js'

        window.fitImageToDevicePixelRatio = @BlogConfig.ImageSettings.FitImageToDevicePixelRatio.ToString().ToLower();
        viewpost.resizeImages();
        viewpost.renderCodeHighlighter();
        viewpost.RenderLaTeX();
        viewpost.applyImageZooming();

        @if (BlogConfig.AdvancedSettings.WarnExternalLink)
        {
            <text>
                postSlug.warnExtLink();
            </text>
        }
    </script>
}

<div class="alert alert-info">
    @SharedLocalizer["This is a preview for draft content."]
</div>

<article class="article-post-slug position-relative rounded-3 shadow-sm border bg-white mb-4" data-postid="@Model.Post.Id" lang="@Model.Post.ContentLanguageCode">
    @if (Model.Post.IsFeatured)
    {
        <partial name="_FeaturedTag" />
    }

    <header class="post-header @(BlogConfig.ContentSettings.PostTitleAlignment == PostTitleAlignment.Center ? "text-center" : null)">
        <h1 class="post-title">
            @Model.Post.Title
        </h1>

        <hr class="d-none d-md-block" />
    </header>

    @if (!string.IsNullOrWhiteSpace(Model.Post.HeroImageUrl))
    {
        <div class="post-hero-image-container text-center mb-3">
            <img src="@Helper.SterilizeLink(Model.Post.HeroImageUrl)" class="post-hero-image img-fluid rounded-3 shadow-sm" />
        </div>
    }

    <section class="post-content clearfix">
        <partial name="_PostContentRender" model="Model.Post.PostContent" />
    </section>
    @if (BlogConfig.ContentSettings.ShowPostFooter)
    {
        <section class="post-footer clearfix">
            @Html.Raw(BlogConfig.ContentSettings.PostFooterHtmlPitch)
        </section>
    }

    <partial name="_PostActions" model="Model.Post" />
</article>

<div class="modal fade" id="imgzoomModal" tabindex="-1" role="dialog" aria-labelledby="imgzoomModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-imgzoom" role="document" style="max-width: 100%">
        <div class="modal-content">
            <img id="imgzoom" alt="imgzoom" class="img-fluid" />
        </div>
    </div>
</div>

@if (BlogConfig.AdvancedSettings.WarnExternalLink)
{
    <partial name="_ExternalLink" />
}

<partial name="_PostForestageAdmin" />